package uk.ac.ebi.uniprot.wikipedia.model;

/**
 * Created with IntelliJ IDEA.
 * User: ljgarcia
 * Date: 02/07/12
 * Time: 14:51
 * To change this template use File | Settings | File Templates.
 */
public class GeneAccessionPair implements Comparable<GeneAccessionPair>{
    private String gene, accession;

    public GeneAccessionPair() {
        this("", "");
    }

    public GeneAccessionPair(String gene, String accession) {
        this.gene = gene;
        this.accession = accession;
    }

    public String getGene() {
        return gene;
    }

    public void setGene(String gene) {
        this.gene = gene;
    }

    public String getAccession() {
        return accession;
    }

    public void setAccession(String accession) {
        this.accession = accession;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        GeneAccessionPair that = (GeneAccessionPair) o;

        if (!accession.equals(that.accession)) return false;
        if (!gene.equals(that.gene)) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = gene.hashCode();
        result = 31 * result + accession.hashCode();
        return result;
    }

    /**
     * Returns a string representation of the object.
     *
     * @return a string representation of the object.
     */
    @Override
    public String toString() {
        return "(" + this.gene + ", " + this.accession + ")";
    }

    /**
     * Compares this object with the specified object for order.  Returns a
     * negative integer, zero, or a positive integer as this object is less
     * than, equal to, or greater than the specified object.
     *
     * @param o the object to be compared.
     * @return a negative integer, zero, or a positive integer as this object
     *         is less than, equal to, or greater than the specified object.
     * @throws ClassCastException if the specified object's type prevents it
     *                            from being compared to this object.
     */
    @Override
    public int compareTo(GeneAccessionPair o) {
        return this.toString().compareTo(o.toString());
    }
}
